/*    */ package com.zimbra.cs.service.admin;
/*    */ 
/*    */ import com.zimbra.common.account.Key.DistributionListBy;
/*    */ import com.zimbra.common.service.ServiceException;
/*    */ import com.zimbra.common.soap.AdminConstants;
/*    */ import com.zimbra.common.soap.Element;
/*    */ import com.zimbra.common.util.Log;
/*    */ import com.zimbra.common.util.ZimbraLog;
/*    */ import com.zimbra.cs.account.Group;
/*    */ import com.zimbra.cs.account.Provisioning;
/*    */ import com.zimbra.cs.account.accesscontrol.AdminRight;
/*    */ import com.zimbra.cs.account.accesscontrol.Rights.Admin;
/*    */ import com.zimbra.soap.JaxbUtil;
/*    */ import com.zimbra.soap.ZimbraSoapContext;
/*    */ import com.zimbra.soap.admin.message.RenameDistributionListRequest;
/*    */ import java.util.List;
/*    */ import java.util.Map;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class RenameDistributionList
/*    */   extends AdminDocumentHandler
/*    */ {
/*    */   public boolean domainAuthSufficient(Map context)
/*    */   {
/* 46 */     return true;
/*    */   }
/*    */   
/*    */ 
/*    */ 
/*    */ 
/*    */   public boolean defendsAgainstDelegateAdminAccountHarvesting()
/*    */   {
/* 54 */     return true;
/*    */   }
/*    */   
/*    */   public Element handle(Element request, Map<String, Object> context) throws ServiceException
/*    */   {
/* 59 */     ZimbraSoapContext zsc = getZimbraSoapContext(context);
/* 60 */     Provisioning prov = Provisioning.getInstance();
/* 61 */     RenameDistributionListRequest req = (RenameDistributionListRequest)JaxbUtil.elementToJaxb(request);
/* 62 */     String id = req.getId();
/* 63 */     String newName = req.getNewName();
/* 64 */     Group group = prov.getGroup(Key.DistributionListBy.id, id);
/* 65 */     defendAgainstGroupHarvesting(group, Key.DistributionListBy.id, id, zsc, Rights.Admin.R_renameGroup, Rights.Admin.R_renameDistributionList);
/*    */     
/*    */ 
/*    */ 
/* 69 */     checkDomainRightByEmail(zsc, newName, Rights.Admin.R_createDistributionList);
/*    */     
/* 71 */     String oldName = group.getName();
/* 72 */     prov.renameGroup(id, newName);
/*    */     
/* 74 */     ZimbraLog.security.info(ZimbraLog.encodeAttrs(new String[] { "cmd", "RenameDistributionList", "name", oldName, "newName", newName }));
/*    */     
/*    */ 
/*    */ 
/* 78 */     group = prov.getGroup(Key.DistributionListBy.id, id);
/* 79 */     if (group == null) {
/* 80 */       throw ServiceException.FAILURE("unable to get distribution list after rename: " + id, null);
/*    */     }
/* 82 */     Element response = zsc.createElement(AdminConstants.RENAME_DISTRIBUTION_LIST_RESPONSE);
/* 83 */     GetDistributionList.encodeDistributionList(response, group);
/* 84 */     return response;
/*    */   }
/*    */   
/*    */   public void docRights(List<AdminRight> relatedRights, List<String> notes)
/*    */   {
/* 89 */     relatedRights.add(Rights.Admin.R_renameDistributionList);
/* 90 */     relatedRights.add(Rights.Admin.R_createDistributionList);
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/service/admin/RenameDistributionList.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */